User defined function in MATLAB